package com.woniuxy.dudugua.controller;

import com.woniuxy.dudugua.entity.Store;
import com.woniuxy.dudugua.service.ProductService;
import com.woniuxy.dudugua.service.StoreService;
import com.woniuxy.dudugua.util.Result;
import com.woniuxy.dudugua.util.view.StoreNavBar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("store")
public class StoreController {
    @Autowired
    private StoreService storeService;
    //根据店铺id获取店铺的信息
    @RequestMapping("getstore")
    public Result getStore(int id){
        Store store = storeService.selectById(id);
        return new Result("200","success",store,null);
    }
    //根据店铺信息获取商品名和商品的封面图地址 用于店铺页面轮播图
    @RequestMapping("getNavBar")
    public Result getNavbar(int id){
        List<StoreNavBar> storeNavBars = storeService.selectNavbarById(id);
        return new Result("200","success",null,storeNavBars);
    }
    @RequestMapping("gethotpro")
    public Result selectStoreHotPro(int id,int number){
        List<StoreNavBar> storeNavBars = storeService.selectStoreHotProduct(id, number);
        return new Result("200","success",null,storeNavBars);
    }
    @RequestMapping("page")
    public Result selectStoreProductByPage(int pageIndex,int number,int id){
        List<StoreNavBar> storeNavBars = storeService.selectStoreProductsByPage(pageIndex, number, id);
        return new Result("200","success",null,storeNavBars);
    }
}
